package com.east.controller.statistical;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.east.bean.Contract;
import com.east.bean.Fee;
import com.east.bean.OtherFee;
import com.east.service.sale.ContractService;
import com.east.service.statistical.ProjectCostService;
import com.east.utils.PageJson;
import com.east.utils.Pagenation;
import com.east.utils.Result;
import com.east.utils.ResultUtil;
import com.github.pagehelper.Page;
/**
 * 项目成本
 * @author Administrator
 *
 */
@RestController
@RequestMapping("projectCost")
public class ProjectCostController {
	@Autowired
	ProjectCostService projectCostService;
	
	/**
	 * 全查
	 * 分页
	 * @param pagenation
	 * @param key
	 * @return
	 */
	@GetMapping("all")
	@RequiresPermissions("projectCost:all")
	public Result findByPage(Pagenation pagenation,String key,String startTime ,String endTime) {
		Page<ProjectCost> findByPage = projectCostService.findList(pagenation, key,startTime,endTime);
		Object pageJson = new PageJson<ProjectCost>().pageJson(findByPage);
		return ResultUtil.success(pageJson);
	}
	/**
	 * 费用明细
	 * @param id
	 * @return
	 */
	@GetMapping("findOne")
	@RequiresPermissions("projectCost:findOne")
	public Result findOne(Integer id) {
		ProjectCost findOne = projectCostService.findOne(id);
		return ResultUtil.success(findOne);
	}
	/**
	 * 采购明细
	 * @param id
	 * @return
	 */
	@GetMapping("findContract")
	@RequiresPermissions("projectCost:findContract")
	public Result findContract(Integer id) {
		 List<Contract> findByContract = projectCostService.findByContract(id);
		return ResultUtil.success(findByContract);
	}
	/**
	 * 项目费用明细
	 * @param id
	 * @return
	 */
	@GetMapping("findFee")
	@RequiresPermissions("projectCost:findFee")
	public Result findFee(Integer id) {
		 List<Fee> findByFee = projectCostService.findByFee(id);
		return ResultUtil.success(findByFee);
	}
	/**
	 * 其他费用明细
	 * @param id
	 * @return
	 */
	@GetMapping("findOther")
	@RequiresPermissions("projectCost:findOther")
	public Result findOther(Integer id) {
	List<OtherFee> findByOtherFee = projectCostService.findByOtherFee(id);
		return ResultUtil.success(findByOtherFee);
	}
	
	
}
